package chenji.itemeditor.help;

import java.util.LinkedHashSet;

import org.bukkit.entity.Player;

import com.google.common.collect.Sets;

public class CommonHelpPage {
	LinkedHashSet<String> set = Sets.newLinkedHashSet();

	private CommonHelpPage(LinkedHashSet<String> set) {
		this.set = set;
	}

	public CommonHelpPage() {
	}

	public CommonHelpPage addLine(String l) {
		this.set.add(l);
		return this;
	}

	public void send(Player p) {
		for (String line : set) {
			p.sendMessage(line);
		}
	}

	public void increase(int loc, String message) {
		int nowloc = 0;
		LinkedHashSet<String> set = Sets.newLinkedHashSet();
		for (String hl : this.set) {
			set.add(hl);
			if (loc == nowloc) {
				set.add(message);
			}
			nowloc++;
		}
		this.set = set;
	}

	public CommonHelpPage clone() {
		return new CommonHelpPage(this.set);
	}

}
